package com.zjd.dao;

import com.zjd.domain.Category;
import com.zjd.domain.Route;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface RouteDao {
    @Results(id = "Route_Result",
            value = {
                    @Result(column = "rid", property = "rid"),
                    @Result(column = "rname", property = "rname"),
                    @Result(column = "price", property = "price"),
                    @Result(column = "routeIntroduce", property = "routeIntroduce"),
                    @Result(column = "rflag", property = "rflag"),
                    @Result(column = "rdate", property = "rdate"),
                    @Result(column = "isThemeTour", property = "isThemeTour"),
                    @Result(column = "num", property = "num"),
                    @Result(column = "cid", property = "cid"),
                    @Result(column = "rimage", property = "rimage"),
                    @Result(column = "sid", property = "sid"),
                    @Result(column = "sourceId", property = "sourceId"),
                    @Result(column = "cid", property = "category", javaType = Category.class,
                            one = @One(
                                    select = "com.zjd.dao.CategoryDao.selectCategoryByRouteId"
                            ))
            })
    @Select("SELECT * FROM tab_route")
    List<Route> selectAllRoute();

    @ResultMap("Route_Result")
    @Select("SELECT * FROM tab_route WHERE cid = #{cid} ")
    List<Route> selectRouteByCategoryId(int cid);
}
